from time import time


def time_of_sort(filename):
    f = open('datar (1).txt', 'r')
    data = f.readlines()
    f.close()
    for i in range(len(data)):
        data[i] = int(data[i])

    start_time = time()
    for i in range(len(data) - 1):
        is_sorted = True
        for j in range(len(data) - i - 1):
            if data[j] > data[j + 1]:
                data[j], data[j + 1] = data[j + 1], data[j]
                is_sorted = False
        if is_sorted:
            break
    end_time = time()
    return (end_time - start_time) * 1000


print(time_of_sort('datar'))
print(time_of_sort('datas'))
print(time_of_sort('datasort'))
